//
//  RSCommonBadgeView.m
//  RenShineDoctor
//
//  Created by 黄强强 on 15/11/6.
//  Copyright © 2015年 杭州岐黄信息技术有限公司. All rights reserved.
//

#import "HQQSettingBadgeView.h"
#import "HQQSettingConfig.h"
#import <HQQCommonTools.h>

@interface HQQSettingBadgeView ()

@end

@implementation HQQSettingBadgeView

+ (instancetype)badgeView
{
    return [[self alloc] init];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
//        [self setBackgroundImage:[UIImage resizedImageWithNamed:HQQSettingBadgeViewImage] forState:UIControlStateNormal];
    }
    return self;
}

- (void)setBadgeValue:(NSString *)badgeValue
{
    _badgeValue = badgeValue;
    
    if (!badgeValue) {
        self.frame = CGRectZero;
        return;
    }
    
    [self setTitle:badgeValue forState:UIControlStateNormal];
    
    CGRect frame = [badgeValue hqq_rectWithFont:self.titleLabel.font];
    CGFloat bgW = self.currentBackgroundImage.size.width;
    frame.size.width += 10;
    frame.size.height = self.currentBackgroundImage.size.height;
    if (frame.size.width < bgW) {
        frame.size.width = bgW;
    }
    
    CGRect tempFrame = self.frame;
    tempFrame.size = frame.size;
    
    self.frame = tempFrame;
}

- (void)setHighlighted:(BOOL)highlighted {};

@end
